#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_calculate_clicked()
{
    float price = ui->singleValue->value();
    int   num = ui->weight->value();
    float total_price = price * num;
    ui->totalValue->setValue(total_price);
}

void Widget::on_Dec_transform_clicked()
{
    int value = ui->Dec->value();
    ui->Bin->setValue(value);
    ui->Hex->setValue(value);
}

void Widget::on_singleValue_valueChanged(double arg1)
{
    Q_UNUSED(arg1);
    on_calculate_clicked();
}

void Widget::on_weight_valueChanged(int arg1)
{
    Q_UNUSED(arg1);
    on_calculate_clicked();
}

void Widget::on_Bin_transform_clicked()
{
    int value = ui->Bin->value();
    ui->Dec->setValue(value);
    ui->Hex->setValue(value);
}

void Widget::on_Hex_transform_clicked()
{
    int value = ui->Hex->value();
    ui->Dec->setValue(value);
    ui->Bin->setValue(value);
}
